<?
session_start();
include('conn.php');
$id=$_REQUEST["id"];

switch($id)
{
	case '1':
		$qry1 = "SELECT * from transactionmast where status=0 order by trnid desc";
		$qry = mysql_query($qry1);
		$data = array();
		$i=1;
		while($rows = mysql_fetch_array($qry)) 
		{
			$qry2 = "select couriername from couriermast where courierid = '".$rows["courierid"]."'";
			$rows2 = mysql_fetch_row(mysql_query($qry2));
			
			$qry3 = "select districtname from districtmast where districtid = '".$rows["districtid"]."'";
			$rows3 = mysql_fetch_row(mysql_query($qry3));
			
			$data[] = array("Sr_NO" => $i++,
						"trnid" => $rows['trnid'],
						"inwarddate" => $rows['inwarddate'],
						"proposalno" => $rows['proposalno'],
						"policyno" => $rows['policyno'],
						"filebarcode"=> $rows['filebarcode'],
						"cartonbarcode"=> $rows['cartonbarcode'],
						"awbno"=> $rows['awbno'],
						"courierid"=> $rows2[0],
						"districtid"=> $rows3[0],
						"remarks"=> $rows['remarks'],
						"enteredby"=> $rows['enteredby'],
						"entrydt"=> $rows['entrydt'],
						"status"=> $rows['status']
				  );
		}
		echo json_encode($data);
		break;
		
	case '2':
		$qry1 = "SELECT couriername from couriermast where status=1 order by couriername";
		$qry = mysql_query($qry1);
		$data = array();		
		while($rows = mysql_fetch_array($qry))
			$data[] = $rows['couriername'];
		echo json_encode($data);
		break;
	
	case '3':
		$qry1 = "SELECT districtname from districtmast where status=1 order by districtname";
		$qry = mysql_query($qry1);
		$data = array();		
		while($rows = mysql_fetch_array($qry))
			$data[] = $rows['districtname'];
		echo json_encode($data);
		break;
		
	case '4':
		for($i=30;$i<=52;$i++){
			$qry1 = "insert into STBDetails values('','$i','$i','1','22','','admindev',now(),null,null)";
			echo "<br>$qry1";
			$qry = mysql_query($qry1);
		}		
		echo json_encode($qry);
		break;
}


?>